﻿using ConfExpert.Forms.Base;
using DevTeam;
using System;

namespace ConfExpert.Forms
{
    public partial class OwnerDegistir : XForm
    {
        public OwnerDegistir()
        {
            InitializeComponent();
        }

        private void OwnerDegistir_Load(object sender, EventArgs e)
        {
            gleOwner.Properties.Assign(RI(Rp.V_Customer));
            gleOwner.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            txtTop.EditValueChanged += txtTop_EditValueChanged;
            btnKaydet.Click += btnKaydet_Click;

            gridControl1.Size = new System.Drawing.Size(gridControl1.Width, 500);
        }

        void txtTop_EditValueChanged(object sender, EventArgs e)
        {
            gridView1.Init("GetRollOwner", txtTop.EditValue.ToInt());
            gridView1.MakeColumnInvisible("OwnerId");
            gridView1.MakeReadOnly();

            gleOwner.EditValue = null;
            if (gridView1.DataTable().Rows.Count > 0)
            {
                gleOwner.EditValue = gridView1.GetFocusedDataRow()["OwnerId"].ToInt();
                gridView1.BestFitColumns();
            }
        }

        void btnKaydet_Click(object sender, EventArgs e)
        {
            ExecuteDataTable("UpdOwnerDuzeltme", txtTop.EditValue.ToInt(), gleOwner.EditValue.ToInt(), txtGerekce.Text, WhoAmI);
            Notify("Güncellendi");
        }
    }
}
